// 账户流水明细

import { FileListType } from '@renderer/types/global'
import axios from 'axios'
const modelUrl = '/finance'
export interface AccountReq {
  tradeDt?: string
  accountTradeDetailId?: string
  bankAccount: string
  feeCategory: string
  feeUsage: string
  incomeAmt: number
  expendAmt: number
  accountBalance: number
  usedObj: string
  tradeType: number
  remark: string
  fileList?: FileListType[]
  accountName: string
}
export interface AccountRes {
  currentPage?: number
  pageSize?: number
  totalPage?: number
  totalCount?: number
  list: AccountResItem[]
}
export interface AccountResItem {
  accountTradeDetailId?: string // 帐号流水明细ID
  bankAccount: string // 银行帐户
  feeCategory: string // 费用分类
  feeUsage: string // 费用用途
  incomeAmt: number // 收入
  expendAmt: number // 支出
  accountBalance: number // 账户余额
  usedObj: string // 作用对象
  tradeType: number // 流水类型
  remark: string // 备注
  tenantId: number // 租户ID
  index?: number // 导出的序号
  fileList?: FileListType[]
  accountName: string
}
export interface AccountListSearch {
  bankAccount?: string // 银行帐户
  feeCategory?: string // 费用分类
  feeUsage?: string // 费用用途
  usedObj?: string // 作用对象
  createdDt: string[] // 创建时间
  createdStartDate?: string // 创建时间开始
  createdEndDate?: string // 创建时间结束
  tradeType?: number // 流水类型
}

export interface AccountTradeSumType {
  list: {
    acccountName: string
    incomeAmt: string
    bankAccount: string
    accountBalance: string
    expendAmt: string
  }[]
}

export function editAccount(data: AccountReq) {
  return axios.post<AccountRes>(modelUrl + '/accountTradeDetailAdit', data)
}

export function delAccount(data: { accountTradeDetailId: string }) {
  return axios.post<object>(modelUrl + '/accountTradeDetailDel', data)
}

export function getAccountDetail(data: { accountTradeDetailId: string }) {
  return axios.post<AccountResItem>(modelUrl + '/accountTradeDetailDetail', data)
}

export function getAccountAllList(data?: AccountListSearch) {
  return axios.post<AccountRes>(modelUrl + '/accountTradeDetailList', data)
}

export function getAccountPageList(data: AccountListSearch) {
  return axios.post<AccountRes>(modelUrl + '/accountTradeDetailPage', data)
}

export function getAccountBalance(data: { bankAccount?: string; accountName?: string }) {
  return axios.post<AccountRes>(modelUrl + '/getAccountBalance', data)
}

export function getAccountTrade(data: { createdStartDate: string; createdEndDate: string }) {
  return axios.post<AccountTradeSumType>(modelUrl + '/accountTradeDetailStat', data)
}

// // 私帐
// export interface PrivateAccountReq {
//   customerId?: number
//   customerName: string
//   customerAddress: string
//   taxNo: string
//   bankAccount: string
//   payeeAcctBank: string
//   contactName: string
//   contactPhone: string
//   remark: string
// }
// export interface PrivateAccountRes {
//   currentPage?: number
//   pageSize?: number
//   totalPage?: number
//   totalCount?: number
//   list: PrivateAccountResItem[]
// }
// export interface PrivateAccountResItem {
//   customerId: string
//   customerName: string
//   customerAddress: string
//   taxNo: string
//   bankAccount: string
//   payeeAcctBank: string
//   contactName: string
//   contactPhone: string
//   remark: string
//   createdDt: string
//   createdBy: string
//   updatedBy: string
//   updatedDt: string
// }
// export interface PrivateAccountListSearch {
//   customerName?: string
//   taxNo?: string
//   contactName?: string
//   createTime: string[]
// }

// export function editPrivateAccount(data: PrivateAccountReq) {
//   return axios.post<PrivateAccountRes>(modelUrl + '/erpPrivateAccountAdit', data)
// }

// export function delPrivateAccount(data: { customerId: string }) {
//   return axios.post<object>(modelUrl + '/erpPrivateAccountDel', data)
// }

// export function getPrivateAccountDetail(data: { customerId: string }) {
//   return axios.post<PrivateAccountRes>(modelUrl + '/erpPrivateAccountDetail', data)
// }

// export function getPrivateAccountAllList(data?: PrivateAccountListSearch) {
//   return axios.post<PrivateAccountRes>(modelUrl + '/erpPrivateAccountList', data)
// }

// export function getPrivateAccountPageList(data: PrivateAccountListSearch) {
//   return axios.post<PrivateAccountRes>(modelUrl + '/erpPrivateAccountPage', data)
// }
